<?php
    $openid = $_GET['openid'];
    $today = $_GET['today'];                       //当前页数
    $conn = mysqli_connect("localhost", "root", "", "cloudwarehouse");

if (!$conn)
    echo "数据库连接失败！";
else {

    $sql = "SELECT outboundId,outbound_commodityName,outboundBag,outboundTotalprice,outboundDate,operationTime,outbound_commodityId,outboundBuyer FROM outboundlist WHERE openid = '$openid' AND outboundDate = '$today'";
    $result = mysqli_query($conn,$sql);

    $name = array();    
	while($row = mysqli_fetch_row($result)) {
        $name[]=$row;  
    } 
     
    
    for($i = 0;$i<sizeof($name);$i++){

        $sqlunit = "SELECT commodityUnit_conversion FROM commodity WHERE commodityId = '{$name[$i][6]}'";
        $unitres = mysqli_query($conn,$sqlunit);
        $as =  mysqli_fetch_row($unitres);
       //  $name[$i][7] = $as[0];
        
        $name[$i][8] = intval(floor($name[$i][2] /$as[0]));
        $name[$i][2] = $name[$i][2]  % $as[0];
        
    }
    array_multisort(array_column($name,'0'),SORT_DESC,$name); 
    echo json_encode($name);

    
}




?>